<template>
  <div class="sign">
    <div class="sign-header">
      <router-link to="/me" tag="b" class="icon">x</router-link>
      <span>帮助</span>
    </div>
    <div class="sign-content">
      <div class="des">
        <h2>登陆后可展示自己</h2>
        <p>登录即表同意<a href="">用户协议</a>和<a href="">隐私政策</a></p>
      </div>
        <div class="inp">
          <input v-model="number"  type="text" class="inp-controll" placeholder="请输入账号">
        </div>
        <div class="inp">
          <input v-model="password" @input="changeTel" type="password" class="inp-controll" placeholder="请输入密码">
        </div>
      <div class="code-btn">
        <button :disabled="disabled" @click="getCode" :class="[btnBg?'active':'']">登录</button>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data(){
    return{
      telErea:"",
      showMask:false,
      disabled:true,
      btnBg:false,
      password:'',
      number:'',
      names:'',
    }
  },
  methods:{
    getCode(){
    //  写登陆功能 1.先登陆 2.传值给跳转的页面
    //   let number=this.number;
    //   let password=this.password;
      let params={number:this.number,password:this.password}
      axios.post("http://localhost:9999/tplogin",{params:params}).then((res)=>{
        if (res.data.code==2){
          this.names=res.data.data[0].name;
          sessionStorage.setItem('user',JSON.stringify(res.data.data[0]))
          this.$router.push({
            path:'/me',
            name:'me',
            // params:{
            //   number:this.names
            // }
          });
        }else {
          alert("密码或账号错误")
        }
      })
    },
    show(){
      this.showMask=true
    },
    close(){
      this.showMask=false;
    },
    changeTel(e){
      this.password=e.target.value;
      if (this.password!=null){
        this.btnBg=true;
        this.disabled=false;
      }else {
        this.btnBg=false;
        this.disabled=true;
      }
    }
  },
}
</script>

<style>
ul li{
  list-style: none;
}
.sign{
  padding: 30px;
}
.sign-header{
  display: flex;
  justify-content: space-between;
}
.sign-header .icon{
  font-size: 30px;
}
.sign-content{
  padding: 40px 10px;
}

.sign .sign-content .inp{
  height: 50px;
}
.des h2{
  font-size: 24px;
  font-weight: bold;
}
.des p{
  line-height:40px;
  color: #666;
}
.des p a{
  color: #628DB8;
  padding: 0 5px;
}

.inp-controll{
  height: 36px;
  background-color: #f9f9f9;
  border: none;
  width: 90%;
  margin-left: 10px;
  outline:medium;
}
input{
  caret-color:#fe2c55
}
input::-webkit-input-placeholder{
  color:#ccc;
}
.not-sign p{
  color:#ccc;
  font-size: 14px;
  margin-top: 10px;
}
.code-btn button{
  margin: 20px 0;
  width: 100%;
  padding: 15px 0;
  border: none;
  color: #ffffff;
}
.code-btn .active{
  color: #ffffff;
  background-color: #FE2c55;
}

</style>